package com.gopay.common;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 操作返回对象
 * 
 * @Result.java
 * @author yaobo
 * @2012-12-7 下午3:32:25 www.gopay.com.cn Inc.All rights reserved.
 */
public class Result implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -1437037370854633535L;
    /**
     * 当前操作是否成功
     */
    private boolean success;

    /**
     * 业务ID
     */
    private String valueId;
    /**
     * 订单状态 
     */
    private boolean orderStatus=true;
    /**
     * 订单明确失败状态(ture：是；false：否)
     */
    private boolean orderFail = false;
    /**
     * 错误信息
     */
    private String resultCode;
    
    /**
     * 错误描述
     */
    private String errorMsg;

    /**
     * 快捷API失败通知，银行返回码   工行银企直连银行返回码
     */
    private String bankRetCode;

    /**
     * 返回参数
     */
    private Map<String, Object> map = new HashMap<String, Object>();

    /**
     * 默认键值
     */
    private final static String DEFAULT_MODEL = "RESULT_DEFAULT_MODEL";

    public Result() {
    }

    public Result(boolean success) {
        this.success = success;
    }
    public boolean isOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(boolean orderStatus) {
		this.orderStatus = orderStatus;
	}

	public void setDefaultModel(Object obj) {
        map.put(DEFAULT_MODEL, obj);
    }

    public void setModel(String key, Object value) {
        map.put(key, value);
    }

    public Object getModel(String key) {
        return map.get(key);
    }

    public Object getDefaultModel() {
        return map.get(DEFAULT_MODEL);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getValueId() {
        return valueId;
    }

    public void setValueId(String valueId) {
        this.valueId = valueId;
    }

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }      

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public void put(String key, Object value) {
        this.map.put(key, value);
    }

    public Object get(String key) {
        return map.get(key);
    }

    public boolean isOrderFail() {
        return orderFail;
    }

    public void setOrderFail(boolean orderFail) {
        this.orderFail = orderFail;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Result{");
        sb.append("success=").append(success);
        sb.append(", valueId='").append(valueId).append('\'');
        sb.append(", orderStatus=").append(orderStatus);
        sb.append(", orderFail=").append(orderFail);
        sb.append(", resultCode='").append(resultCode).append('\'');
        sb.append(", errorMsg='").append(errorMsg).append('\'');
        sb.append(", bankRetCode='").append(bankRetCode).append('\'');
        sb.append(", map=").append(map);
        sb.append('}');
        return sb.toString();
    }

    public String getBankRetCode() { return bankRetCode; }

    public void setBankRetCode(String bankRetCode) { this.bankRetCode = bankRetCode; }
}
